<%-- 
    Document   : modifyAnnonce
    Created on : Jun 15, 2013, 4:00:47 PM
    Author     : Anna SAELEE
--%>

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link type="text/css" rel="stylesheet" href="style.css"/>
        <title>Modifier les nouvelles</title>
    </head>
    <%  Connection conn;
        Statement stmt;
        ResultSet rs;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dormitorymanagement", "root", "root");
            stmt = conn.createStatement();%>

    <body>
        <div class="wrapper">
            <div class="header"></div>
            <div class="navigator"> <a href="#">MENU</a> > <a href="#">SUBMENU</a> 30*1000 </div>
            <div class="workspace">
                <%@include file="connect.jsp" %>
                <div class="workspace2">
                    <h3>Modifier la nouvelle</h3><br/>
                    <% String nid = (String) request.getParameter("newsID");
                        String sql = "SELECT subject, detail FROM news WHERE nid=" + nid;
                        rs = stmt.executeQuery(sql);
                        if (rs.next()) {
                    %>
                    <form method="post" action="Update" name="updateNews">
                        <input type="hidden" name="typeMss" value="updateNews"/>
                        <input type="hidden" name="newsID" value="<%=nid%>"/>
                        <table width="100%" border="0">
                            <tr>
                                <th>Sujet: </th>
                                <td>
                                    <textarea name="subject" rows="1" cols="50"><%= rs.getString("subject")%></textarea>
                                </td>
                            </tr>
                            <tr>
                                <th>Détail: </th>
                                <td>
                                    <textarea name="detail" rows="20" cols="50"><%= rs.getString("detail")%></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <input type="submit" name="editNews" value="Mettre à jour cette nouvelle"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                    <% } else {%>
                    Ne pas pouvoir connecter au serveur, reessayez-vous à l'autre fois.
                    <% }%>
                </div>
                <%@include file="sidespace.jsp" %>
            </div>
            <div class="footer"> FOOTER 80*1000 </div>
        </div>
    </body>
    <% } finally {
            out.close();
        }
    %>
</html>